<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.25</title>
</head>

<body>
<?php
	if(isset($_POST['str1']) && isset($_POST['goc']) && isset($_POST['thaythe']))
	{
		$str1=$_POST['str1'];
		$goc=$_POST['goc'];
		$thaythe=$_POST['thaythe'];
		$kq=preg_replace("/\b$goc\b/u", $thaythe, $str1);
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_25.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2" bgcolor="#FF3300" style="text-align: center; font-weight: bold; color: #FFF; font-size: 24px;">THAY THỀ TỪ TRONG CHUỖI</td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF">Chuỗi:</td>
      <td bgcolor="#FFCCFF"><input name="str1" type="text" id="str1" value="<?php echo $str1;?>" size="50" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF">Từ gốc:</td>
      <td bgcolor="#FFCCFF"><input name="goc" type="text" id="goc" value="<?php echo $_POST['goc'];?>" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF">Từ thay thế:</td>
      <td bgcolor="#FFCCFF"><input name="thaythe" type="text" id="thaythe" value="<?php echo $_POST['thaythe'];?>" /></td>
    </tr>
    <tr style="text-align: center">
      <td colspan="2" bgcolor="#FFCCFF"><input style="background-color:#F93" type="submit" name="submit" id="submit" value="Thay thế" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFCCFF">&nbsp;</td>
      <td bgcolor="#FFCCFF"><input style="background-color:#FFC" name="str2" type="text" disabled="disabled" id="str2" value="<?php echo $kq;?>" size="50" /></td>
    </tr>
  </table>
</form>
</body>
</html>